/**
 * A StatusBar shows information about the currently selected Shapes.
 * 
 * @author Matthias.Hauswirth@usi.ch
 */

package ch.usi.inf.pf2.gui;

import javax.swing.JPanel;
import javax.swing.JLabel;

public final class StatusBar extends JPanel {

	private static final long serialVersionUID = 1L;
	private final Model model;
	private final JLabel label;

	public StatusBar(final Model model) {
		this.model = model;
		label = new JLabel("Welcome to CircSim");
		add(label);

		// register listeners
		Model.getSelection().addSelectionListener(new SelectionListener() {
			@Override
			public void selectionChanged() {
				update();
			}
		});
	}

	/**
	 * This method sets the text on a label on the GUI. This label is a status
	 * bar that indicates how and what objects are selected.
	 */
	private void update() {
		final String message = Model.getSelection().getSize()
				+ " objects selected";
		label.setText(message);
	}

}
